Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: true,
    avatarUrl: '',
    nickname:''
  },

  intouser(){
    wx.navigateTo({
      url: '/pages/user/user',
    })
  },

  login(){
    wx.navigateTo({
      url: '/pages/login/login',
    })
  },

  GAorder(){
    wx.navigateTo({
      url: '/pages/g-a-order/g-a-order',
    })
  },

  coupon(){
    wx.navigateTo({
      url: '/pages/coupon/coupon',
    })
  },

  linkman(){
    wx.navigateTo({
      url: '/pages/linkman/linkman',
    })
  },

  service(){
    wx.navigateTo({
      url: '/pages/service/service',
    })
  },

  insurance(){
    wx.navigateTo({
      url: '/pages/insurance/insurance',
    })
  },

  suggest(){
    wx.navigateTo({
      url: '/pages/suggest/suggest',
    })
  },

  trip(e) {
    const id = e.currentTarget.dataset.id; 
    wx.navigateTo({
      url: `/pages/trip/trip?id=${id}`, 
    });
  },

  payment(e) {
    const id = e.currentTarget.dataset.id; 
    wx.navigateTo({
      url: `/pages/trip/trip?id=${id}`, 
    });
  },

  history(e) {
    const id = e.currentTarget.dataset.id; 
    wx.navigateTo({
      url: `/pages/trip/trip?id=${id}`, 
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    const userInfo = wx.getStorageSync('userInfo');
    if (userInfo) {
        this.setData({
            userInfo: false,
            avatarUrl: userInfo.avatarUrl, // 从缓存中获取头像
            nickname: userInfo.nickname,   // 从缓存中获取昵称
        });
    } else {
        this.setData({
            userInfo: true
        });
    }

},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

})